<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="./tag.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>My JSP 'testupload.jsp' starting page</title>
		<script src="${ctx }/js/jquery.js" type="text/javascript"></script>
		<script src="${ctx }/js/ajaxfileupload.js" type="text/javascript"></script>
		<script type="text/javascript">
	function ajaxFileUpload()
	{
		$("#loading")
		.ajaxStart(function(){
			$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});

		$.ajaxFileUpload
		(
			{
				url:'${ctx }/upload.do?method=process',
				secureuri:false,
				fileElementId:'fileToUpload',
				dataType: 'json',
				success: function (data, status)
				{
				    alert(data.msg);
				},
				error: function (data, status, e)
				{
				    alert(data.error)
				}
			}
		)
		return false;
	}
	</script>
	</head>

	<body>
		<img id="loading" src="${ctx }/images/loading.gif" style="display: none;">
		<form name="form" action="" method="POST">
		<table cellpadding="0" cellspacing="0">
			<tr>
				<th>
					Please select a file and click Upload button
				</th>
			</tr>
			<tr>
				<td>
					<input id="fileToUpload" type="file" size="45" name="fileToUpload"
						class="input">
				</td>
			</tr>
			<tr>
				<td>
					<button class="button" id="buttonUpload"
						onclick="return ajaxFileUpload();">
						Upload
					</button>
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>
